{extend name="public/header" /}
{block name="body"}
<body>
{include file="public/common" /}
<fieldset class="layui-elem-field site-demo-button" style="padding:30px;">
    <div class="layui-row">
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md12">
            <form id="form1" class="layui-form layui-form-pane" action="{:url('')}">
            <section class="panel">
                <div class="panel-heading" style="padding:0.8em;">
                    <b>菜单权限(不选择任何权限为拥有所有权限)</b>
                </div>
                <section class="panel panel-padding">
                        {foreach name="AdminMenu" item="vo"}
                        <div class="layui-form-item">
                            <label class="layui-form-label">{$vo.name}</label>
                            <div class="layui-input-block">
                                <input type="checkbox" lay-filter="checkbox" name="menu_purview[{$vo.id}]" title="{$vo.name}" value="{$vo.id}" class="checkAll" {in name="vo.id" value="$info.menu_purview"}checked{/in}>
                                {foreach name="vo.list_sub" item="v" key='k'}
                                <input type="checkbox" value="{$v.id}" name="menu_purview[{$v.id}]" title="{$v.name}" {in name="v.id" value="$info.menu_purview"}checked{/in}>
                                {/foreach}
                            </div>
                        </div>
                        {/foreach}
                </section>
            </section>
                <section class="panel">
                    <div class="panel-heading" style="padding:0.8em;">
                        <b>操作权限 (勾选模块后后面的权限才会生效，不选择任何权限为拥有所有权限)</b>
                    </div>
                    <section class="panel panel-padding">
                        {foreach name="AdminMenu" item="vo"}
                        <div class="layui-form-item">
                            <label class="layui-form-label">{$vo.name}</label>
                            {foreach name="vo.list_sub" item="v" key='k'}
                            <div class="layui-input-block">
                                <input type="checkbox" lay-filter="checkbox" title="{$v.name}">
                                {notempty name="v.act"}
                                    {foreach name="v.act" item="vv" key='kk'}
                                    <input type="checkbox" name="base_purview[{$v.id}_{$kk}]" title="{$vv.name}" value="{$vv.act}" {in name="$vv.act" value="$info.base_purview"}checked{/in}>
                                    {/foreach}
                                {/notempty}
                            </div>
                            {/foreach}
                        </div>
                        {/foreach}
                    </section>
                </section>

                <div class="layui-input-block">
                    <input type="hidden" name="id" type="hidden" value="{$info.id}">
                    <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </form>
        </div>
    </div>
</fieldset>
</body>
{/block}
{block name="script"}
<script>
layui.use('form', function(){
    var form = layui.form;
    var $= layui.jquery;
    //各种基于事件的操作，下面会有进一步介绍
    form.on('checkbox(checkbox)', function(data){
        var child = $(data.elem).parents('.layui-input-block').find('input[type="checkbox"]');
        child.each(function(index, item){
            item.checked = data.elem.checked;
        });
        form.render('checkbox');
    });
});
</script>
{/block}